<?php
import_request_variables("gP");

if($excel > 0)
{
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=sinave_identificacion_".date('d_m_Y_H_i')."HRS.xls");
}

include ('../conex.php');
$sql="select r.id_principal as FOL_ID,
0 as IDE_ID,
r.nEntidad as CVE_EDO,
0 as CVE_JUR,
r.nMunicipio as CVE_MPO,
0 as CVE_LOC,
r.rfc as RFC,
r.cNombre as IDE_NOM,
r.cpaterno as IDE_APE_PAT,
r.cmaterno as IDE_APE_MAT,
concat(r.nedad,'-',r.nmeses,'-',r.ndias) as IDE_FEC_NAC,
0 as CVE_EDO_NAC,
0 as CVE_JUR_NAC,
0 as CVE_MPO_NAC,
0 as IDE_EDA_ANO,
0 as IDE_EDA_MES,
0 as IDE_EDA_DIA,
0 as CVE_OCU,
r.nsexo as IDE_SEX,
concat(r.calle, ' No. ', r.numero) as IDE_CAL,
r.colonia as IDE_COL,
'' as CURP,
r.cp as IDE_CP,
r.telefono as IDE_TEL,
0 as CVE_RGO_EDA,
r.calle1 as IDE_CALLE1,
r.calle2 as IDE_CALLE2,
0 as LATITUD,
0 as LONGITUD
from dat_registro r";

$rs=mysql_query($sql,$link) or die ("No se pudo consultar la informacion<br>".$sql."<br>".mysql_error());
$num = mysql_num_fields($rs);
//echo $num;
echo "<table border=1><tr>";
    	for ($x=0;$x<$num;$x++){ 
		$xcampo = mysql_field_name($rs, $x);
		echo "<td><b>$xcampo</b></td>";
 }
 
 while($arr=mysql_fetch_array($rs)){
 		echo "<tr>";
 		for ($x=0;$x<$num;$x++){ 
		echo "<td>$arr[$x]</td>";
		}
		echo"</tr>";
		 
 }
echo "</tr></table>"; 

?>

